package com.info.provider.service.aliyun.oos;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by pengshuo on 2018/4/11 15:58
 * Description: 阿里云 oos 配置
 * Modified By:
 * Version:
 *
 * @author pengshuo
 */
@Configuration
public class OSSClientConfiguration {

    @Value("${aliyun.oss.endPoint}")
    private String endPoint;

    @Value("${aliyun.oss.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.oss.accessKeySecret}")
    private String accessKeySecret;

    /**
     * OSSClient
     * @return
     */
    @Bean
    public OSSClient oosClient(DefaultCredentialProvider credentialProvider,ClientConfiguration clientConfiguration){
        return new OSSClient(endPoint,credentialProvider,clientConfiguration);
    }

    /** 连接配置 */
    @Bean
    public ClientConfiguration clientConfiguration(){
        return new ClientConfiguration();
    }

    /** 密匙 */
    @Bean
    public DefaultCredentialProvider credentialProvider(){
        return new DefaultCredentialProvider(accessKeyId,accessKeySecret);
    }


}
